const mongoose = require('mongoose')
const baseModel = require('./baseModel')
// 创建一个mongoDB中的模式对象
// 该对象定义约束了数据库中的文档结构
const videoSchema = new mongoose.Schema({
    title: {
        type: String,
        required:true
    },
    description: {
        type: String,
        required: false
    },
    vodVideoID: {
        type: String,
        required: true
    },
    user: { // 标识谁上传的视频
        // 数据库中的userid不是字符串 是mongoose.ObjectId类型
        type: mongoose.ObjectId,
        required: true,
        // 与数据库中的users集合关联
        ref: 'User'
    },
    cover: {
        type: String,
        required: false
    },
   ...baseModel
})
module.exports = videoSchema